package onetotwenty;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

import org.junit.Test;

public class ProblemThree {
	private long smallDivideNumber(long l) {
		for (long i = 2; i <= l; i++) {
			if(l % i == 0) {
				return i;
			}
		}
	
		return l;
	}
	
	@Test
	public void testProbable() {
		assertThat(Util.isPrimeNumber(3L), is(true));
		assertThat(Util.isPrimeNumber(4L), is(false));
		assertThat(Util.isPrimeNumber(25L), is(false));
		assertThat(Util.isPrimeNumber(100L), is(false));
		assertThat(Util.isPrimeNumber(11L), is(true));
	}

	@Test
	public void problem3() {
		long end = 600851475143L;
		while (!Util.isPrimeNumber(end)) {
			end /= smallDivideNumber(end);
		}
	
		assertThat(end, is(6857L));
	}
}